--detector
--有些数据冲突因为load指令造成，只能暂停周期，这里的暂停周期要求处在id段的指令和处在if段的指令全都暂停
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use ieee.std_logic_unsigned.all;

entity detector is
  port (
    id_ex_rm:in std_logic;
    --id_ex_rm:if id_ex have memory read
    id_ex_rd,if_id_rs,if_id_rt:in std_logic_vector(3 downto 0);
    --id_ex_rd:id_ex destination register
    --if_id_rs:if_id first source register
    --if_id_rt:if_id second source register
    pause:out std_logic
    --if pause the pipeline
  ) ;
end entity ; -- detector

architecture arch of detector is
begin
    identifier : process(id_ex_rm,id_ex_rd,if_id_rs,if_id_rt)
    begin
		  pause<='0';
        if (id_ex_rm='1')  then--and (id_ex_rd=if_id_rs or id_ex_rt=if_id_rt)
		      if id_ex_rd=if_id_rs or id_ex_rd=if_id_rt then
					pause<='1';
				end if;
        end if;
    end process ; -- identifier
end architecture ; -- arch